package org.nlp.util;

import redis.clients.jedis.Jedis;

public class optest {
	Jedis jedis = new Jedis("localhost");

	public void setObject() {
		Person person = new Person(100, "alan");
		jedis.set(SerializeUtil.serialize("person:100"), SerializeUtil.serialize(person));
		person = new Person(101, "bruce");
		jedis.set(SerializeUtil.serialize("person:101"), SerializeUtil.serialize(person));
	}

	public Person getObject(int id) {
		byte[] person = jedis.get(("person:" + id).getBytes());
		return (Person) SerializeUtil.unserialize(person);
	}

	public static void main(String[] args) {
		optest test = new optest();
		test.setObject();
		Person person = test.getObject(100);
		System.out.println(person.getId());
		System.out.println(person.getName());
		person = test.getObject(101);
		System.out.println(person.getId());
		System.out.println(person.getName());
	}
}
